package com.example.ai.controller;

import com.example.ai.service.BaiduOcrService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/ocr")
public class OcrController {
    private final BaiduOcrService ocrService;

    public OcrController(BaiduOcrService ocrService) {
        this.ocrService = ocrService;
    }

    @PostMapping("/recognize")
    public ResponseEntity<String> recognizeText(@RequestParam("file") MultipartFile file) {
        String result = ocrService.recognizeText(file);
        return ResponseEntity.ok(result);
    }
} 